<template>
  <div class="permission-container">
    <div class="app-container">
      <!-- 表格 -->
      <el-card>
<<<<<<< HEAD
        <el-tabs> 
       
=======
        <el-tabs>
          <span>用户名:</span>
          <el-input
            style="width: 300px; margin-left: 10px"
            v-model="input"
            placeholder="请输入用户名"
          ></el-input>
          <!-- <el-select v-model="depValue" @change="selectDep" placeholder="请选择" >
              <el-option
                v-for="(item,index) in depList"
                :key="item.id"
                :label="item.name"
                :value="index">
              </el-option>
            </el-select> -->
          <span class="ml-10">电话:</span>
          <el-input
            style="width: 300px; margin-left: 10px"
            v-model="input"
            placeholder="请输入电话"
          ></el-input>
          <!-- <el-select v-model="parValue"  placeholder="请选择" >
              <el-option
                v-for="(item) in parList"
                :key="item.id"
                :label="item.phone"
                :value="item.id">
              </el-option>
            </el-select> -->
          <el-button
            class="ml-10"
            type="primary"
            size="medium"
            icon="el-icon-search"
            @click="search"
            >查询</el-button
          >

>>>>>>> 867a4406ee13ff2a4c6c94ec73605d5ed75a8999
          <!-- 左侧 -->
          <el-tab-pane label="余额明细">
            <el-table row-key="id" :data="list" border>
              <el-table-column label="序号" prop="id" width="50">
                <template #default="{ row }">
                  <!-- <i class="el-icon-receiving" /> -->
                  {{ row.id }}
                </template>
              </el-table-column>
              <el-table-column label="用户id" prop="userId" />
              <el-table-column label="用户余额" prop="balance" />
              <el-table-column label="操作">
                <template slot-scope="scope">
<<<<<<< HEAD
                 <el-popover
                 placement="right"
                 width="400"
                 trigger="click">
              <el-table :data="gridData">
              <el-table-column width="150" property="createTime" label="时间"></el-table-column>
              <el-table-column width="150" property="money" label="消费记录(充值)"></el-table-column>
              <el-table-column width="150" property="money" label="金额"></el-table-column>
     
              </el-table>
              <el-button slot="reference">查询明细</el-button>
             </el-popover>
                  <!-- <el-button size="small" type="danger" @click="handleDelete(scope.row.id)">删除</el-button> -->
                </template>

=======
                  <el-button
                    size="small"
                    type="primary"
                    @click="clickInquire(scope.row)"
                    >查询明细</el-button
                  >
                  <!-- <el-button size="small" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
                  <el-button size="small" type="danger" @click="handleDelete(scope.row.id)">删除</el-button> -->
                </template>
>>>>>>> 867a4406ee13ff2a4c6c94ec73605d5ed75a8999
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </el-card>
      <el-dialog :visible.sync="dialogVisible" width="30%">
        <span>确定删除吗？</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="deleteComfirm">确 定</el-button>
        </span>
      </el-dialog>
    </div>

    <!-- 查询明细弹框  -->
    <el-dialog title="查询明细" :visible="showDialog" @close="closeDialog">
      <el-form v-loading="loading" label-width="100px">
        <el-form-item label="用户id" prop="userId">
          <el-input v-model="formData.userId" type="number" disabled />
        </el-form-item>
        <el-form-item label="用户余额" prop="balance">
          <el-input v-model="formData.balance" type="number" disabled />
        </el-form-item>
      </el-form>

      <template #footer>
        <div style="text-align: right">
          <!-- <el-button @click="closeDialog">否</el-button> -->
          <el-button type="primary" @click="closeDialog">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 分页 -->
    <div align="center">
      <el-pagination
        :current-page.sync="currentPage"
        layout="prev, pager, next, jumper"
        :total="list.length"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>

import {selectAllBalance ,selectBalance,selectAll} from '@/api/qiniu'
export default {

  data() {
    return {
      input:'',
      dialogVisible: false,
      // 分页数据
      currentPage: 1,
      list: [],
      showDialog: false,
      formData: {
        // enVisible: '0', // 0不开启, 1开启 (注意: 不是布尔值, 所以将来需要处理switch)
        user_id: '', // 名称
        balance: '',
  
      },
      loading: false,
      permissionData: [] // 存放用于展示的权限列表数据 (树形结构)
    }
  },
  computed: {
    showTitle() {
      if (this.formData.id) {
        return '查询明细'
      } else {
        return 
      }
    }
  },
  mounted() {
    console.log('进入页面的钩子函数')
    this.selectAll()
  },
  methods: {
    async selectAll() {
      const data = await selectAll()
      this.list = data
    },
    async handleSearch(){
      const res = await await selectBalance({
        id:5
      })
      this.list=res
    },
    clickAdd(type, pid) {
      this.showDialog = true

    },
    closeDialog() {
      this.showDialog = false
      // 重置清空数据
      this.formData = {
        enVisible: '0', // 0不开启, 1开启 (注意: 不是布尔值, 所以将来需要处理switch)
        name: '', // 名称
        code: '', // 权限标识
        description: '', // 描述
        type: '', // 类型, 1一级访问权限, 2二级操作权限
        pid: '' // 添加到哪个节点下, 树形结构渲染的, 点击某个节点时, 也能知道pid是什么
      }
    },
    // 查询功能
    clickInquire(row){
      this.formData = row
      this.formData.postalcode = row.postalCode
      this.showDialog = true
    },
    
    // 删除功能
    handleDelete(id) {
      this.deleteId = id
      this.dialogVisible = true
    },
    async deleteComfirm() {
      this.dialogVisible = false
      await deleteDep({
        id: this.deleteId
      })
      this.$message({
        message: '删除成功',
        type: 'success'
      })
      this.getPermissionList()
    },
    handleEdit(row) {
      // const {postalCode,...formData} = row
      // formData.postalcode = postalCode
      this.formData = row
      this.formData.postalcode = row.postalCode
      this.showDialog = true
    },

    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
    }
  }
}
</script>

<style>
</style>
